import 'package:flutter/material.dart';

class HomeList extends StatelessWidget {
  const HomeList({super.key, required this.notifyList});
  final List notifyList;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        const SizedBox(height: 10),
        Row(children: [
          Image.asset(
            'assets/images/notice@2x.png',
            width: 20,
          ),
          const SizedBox(
            width: 5,
          ),
          const Text(
            '社区',
            style: TextStyle(
              color: Colors.black,
              fontWeight: FontWeight.w700,
            ),
          ),
          const Text(
            '公告',
            style: TextStyle(
              color: Colors.orange,
              fontWeight: FontWeight.w700,
            ),
          ),
        ]),
        ListView(
            physics: const NeverScrollableScrollPhysics(),
            shrinkWrap: true,
            children: notifyList
                .map(
                  (item) => GestureDetector(
                    onTap: () {
                      Navigator.pushNamed(context, '/detail',
                          arguments: item['id']);
                    },
                    child: Container(
                      padding: const EdgeInsets.all(10),
                      margin: const EdgeInsets.only(top: 10),
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(10),
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            item['title'],
                            style: const TextStyle(fontWeight: FontWeight.w700),
                          ),
                          const SizedBox(height: 5),
                          Text(item['content']),
                          Text(
                            item['createdAt'],
                            style: const TextStyle(color: Colors.grey),
                          )
                        ],
                      ),
                    ),
                  ),
                )
                .toList())
      ],
    );
  }
}
